In [1]:
import numpy as np
import h5py
from os import path, rename
from shutil import copyfile
from glob import glob
orig_fname = '/u/ki/swmclau2/des/ds_zheng07/PearceDsCosmo.hdf5' new_fname = '/u/ki/swmclau2/des/ds_zheng07/PearceDsCosmo.hdf5'
orig_fname = '/u/ki/swmclau2/des/ds_zheng07_test/PearceDsCosmoTest.hdf5' new_fname = '/u/ki/swmclau2/des/ds_zheng07_test/PearceDsCosmoTest_littleh_correction.hdf5'

In [7]:
base_dir = '/u/ki/swmclau2/des/Aemulators'
orig_fnames = [#'ds_zheng07/PearceDsCosmo.hdf5', 'ds_zheng07_test/PearceDsCosmoTest.hdf5',
              #'ds_hsab/PearceDsHSABCosmo.hdf5']#, 
               'ds_hsab_test2/PearceDsHSABCosmoTest.hdf5']#,
              #'ds_cab/PearceDsCABCosmo.hdf5', 'ds_cab_test/PearceDsCABCosmoTest.hdf5',
              #'ds_corrab/PearceDsCorrABCosmo.hdf5', 'ds_corrab_test/PearceDsCorrABCosmoTest.hdf5']

In [8]:
tmp_fname = 'tmp.hdf5'

In [9]:
def h_factor(h):
    return np.log10(h)*2

In [10]:
for fname in orig_fnames:
    print fname
    orig_fname = path.join(base_dir, fname)
    dirname = path.dirname(orig_fname)
    new_fname = path.join(dirname, tmp_fname)
    copyfile(orig_fname, new_fname)

    with h5py.File(orig_fname, 'r') as orig_f, h5py.File(new_fname, 'a') as new_f:
        little_hs =  orig_f.attrs['cosmo_param_vals'][:, 4]/100

        #print len(little_hs)
        keys = orig_f.keys()
        if 'attrs' in keys:
            keys.remove('attrs')
        
        for h, dset_key in zip(little_hs, keys):

            orig_data = orig_f[dset_key]['a_1.000']['obs']
            new_data = orig_data+h_factor(h)

            new_f[dset_key]['a_1.000']['obs'][()] = new_data
            
            # TODO cov as well
    
    rename(orig_fname, orig_fname + '_old')
    copyfile(new_fname, orig_fname)


ds_hsab_test2/PearceDsHSABCosmoTest.hdf5

In [ ]:
%%bash
ls /u/ki/swmclau2/des/ds_cab/*.hdf5* -ltr

In [ ]:
mock_measurements_dir = '/afs/slac.stanford.edu/u/ki/swmclau2/Git/pearce/bin/mock_measurements/'

In [ ]:
mock_measurements_files = glob(path.join(mock_measurements_dir, '*ds.npy'))
hs = {'HOD': 0.657317, 'other': 0.6777} for m in mock_measurements_files: print m if 'HOD' in m: h = hs['HOD'] else: h = hs['other'] x = np.load(m) np.save(m + '_old', x) np.save(m , x*h**2 )

In [ ]:
darksky_h = 0.7036893781978598

In [ ]:
covmat_dir = '/u/ki/swmclau2/Git/pearce/bin/covmat/'
for fname in ['wp_ds_full_covmat.npy', 'wp_ds_sim_covmat.npy']: c = np.load(path.join(covmat_dir, fname)) np.save(path.join(covmat_dir, fname+ '_old'), c) np.save(path.join(covmat_dir, fname), c[18:36][18:36]*darksky_h**4) c = np.load(path.join(covmat_dir, 'ds_full_covmat.npy') ) np.save(path.join(covmat_dir, 'ds_full_covmat.npy'+ '_old'), c) np.save(path.join(covmat_dir, 'ds_full_covmat.npy'), c*darksky_h**4)

In [ ]: